package com.fenghongzhang.day005;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


/**
 * A simple {@link Fragment} subclass.
 */
public class RightFragment extends Fragment implements Left_Fragment.MyListener {

    private TextView viewById;
    public RightFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_right, container, false);
         viewById = inflate.findViewById(R.id.r_text);

         getChildFragmentManager();

        FragmentManager childFragmentManager = getChildFragmentManager();
        FragmentTransaction fragmentTransaction = childFragmentManager.beginTransaction();
//        fragmentTransaction.add()
//        fragmentTransaction.hide();
        fragmentTransaction.commit();
        return inflate;
    }

    @Override
    public void sendMessage(String s) {
        viewById.setText(s);
    }
}
